﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace IMCOM.Imagiality.ImageProcessing.Canvas2D.ROI
{
    class HorizontalROIHandle : RectangleROIHandle
    {
        private bool isWest;

        public HorizontalROIHandle(Point center, bool isWest) : base(center)
        {
            this.isWest = isWest;
        }

        public override Rectangle Resize(Point mouseDelta, Rectangle rectangle)
        {
            Point firstPoint;
            Point secondPoint;

            if (isWest)
            {
                firstPoint = new Point(rectangle.X + mouseDelta.X, rectangle.Y);
                secondPoint = new Point(rectangle.Right, rectangle.Bottom);

            }
            else
            {
                firstPoint = new Point(rectangle.X, rectangle.Y);
                secondPoint = new Point(rectangle.Right + mouseDelta.X, rectangle.Bottom);
            }

            rectangle = new Rectangle(firstPoint, new Size(secondPoint.X - firstPoint.X, secondPoint.Y - firstPoint.Y));

            return rectangle;
        }

        public override Cursor GetCursor()
        {
            return Cursors.SizeWE;
        }
    }
}
